package com.itheima.consumer.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class NormalConfig {
    //设置交换机和队列   且绑定队列和死信交换机


    @Bean
    public DirectExchange normalExchange() {
        return new DirectExchange("normal.exchange", true, false);
    }

    @Bean
    public Queue normalQueue() {
       // return new Queue("normal.queue", true);
        //绑定队列和死信交换机
        return QueueBuilder.durable("normal.queue").deadLetterExchange("dlx.exchange").build();
    }


    //设置交换机和队列和之间的绑定关系 routingKey=hi和 死信交换机与死信队列之间的绑定关系 一样
    @Bean
    public Binding Exchangebinding(Queue normalQueue,DirectExchange exchange) {
        return BindingBuilder.bind(normalQueue).to(exchange).with("hi");
    }


}
